home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / sectools / dsniff / decode_x11.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-16  |  623 b   |  40 lines

  1. /*
  2.   decode_x11.c
  3.  
  4.   X11.
  5.   
  6.   Copyright (c) 2000 Dug Song <dugsong@monkey.org>
  7.   
  8.   $Id: decode_x11.c,v 1.1 2000/05/16 17:31:14 dugsong Exp $
  9. */
  10.  
  11. #include <sys/types.h>
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include "decode.h"
  15.  
  16. int
  17. decode_x11(u_char *buf, int len)
  18. {
  19.     char *p, *q;
  20.     int i;
  21.     
  22.     p = buf + 12;
  23.     
  24.     if (strncmp(p, "MIT-MAGIC-COOKIE-1", 18) != 0 || len < 36)
  25.         return (0);
  26.     
  27.     strlcpy(Buf, "MIT-MAGIC-COOKIE-1 ", sizeof(Buf));
  28.     
  29.     p += 20;
  30.     len -= 20;
  31.     q = Buf + 19;
  32.     
  33.     for (i = 0; i < 16 && i < len; i++)
  34.         sprintf(q + (i * 2), "%.2x", (u_char)p[i]);
  35.     strlcat(Buf, "\n", sizeof(Buf));
  36.     
  37.     return (strlen(Buf));
  38. }
  39.  
  40.